#include "../include/threadPool.h"
#include "../include/task.h"
#include <iostream>
#include <memory>

using std::unique_ptr;
using std::cout;


class MyTask
:public Task
{
public:
	void process() override
	{
		::srand(::clock());
		int number = ::rand() % 100;
		cout << std::this_thread::get_id() << " 号线程正在执行任务--->打印 " << number << "\n";
		std::this_thread::sleep_for(std::chrono::seconds(::rand() % 3));
	}
};


int main()
{
	unique_ptr<Task> ptask(new MyTask());

	ThreadPool threadPool(4,10);
	
	threadPool.start();
	
	int num = 20;
	while(num--)
	{
		threadPool.addTask(ptask.get());

	}

	threadPool.stop();




	return 0;
}
